home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Power.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  13.7 KB  |  485 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Power.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __POWER__
  18. #define __POWER__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __MIXEDMODE__
  27. #include <MixedMode.h>
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #if GENERATINGPOWERPC
  35. #pragma options align=mac68k
  36. #endif
  37.  
  38. #ifdef __CFM68K__
  39. #pragma lib_export on
  40. #endif
  41.  
  42.  
  43. enum {
  44. /* Bit positions for ModemByte */
  45.     modemOnBit                    = 0,
  46.     ringWakeUpBit                = 2,
  47.     modemInstalledBit            = 3,
  48.     ringDetectBit                = 4,
  49.     modemOnHookBit                = 5,
  50. /* masks for ModemByte */
  51.     modemOnMask                    = 0x1,
  52.     ringWakeUpMask                = 0x4,
  53.     modemInstalledMask            = 0x8,
  54.     ringDetectMask                = 0x10,
  55.     modemOnHookMask                = 0x20,
  56. /* bit positions for BatteryByte */
  57.     chargerConnBit                = 0,
  58.     hiChargeBit                    = 1,
  59.     chargeOverFlowBit            = 2,
  60.     batteryDeadBit                = 3,
  61.     batteryLowBit                = 4,
  62.     connChangedBit                = 5,
  63. /* masks for BatteryByte */
  64.     chargerConnMask                = 0x1,
  65.     hiChargeMask                = 0x2,
  66.     chargeOverFlowMask            = 0x4,
  67.     batteryDeadMask                = 0x8
  68. };
  69.  
  70. enum {
  71.     batteryLowMask                = 0x10,
  72.     connChangedMask                = 0x20,
  73. /* commands to SleepQRec sleepQProc */
  74.     sleepRequest                = 1,
  75.     sleepDemand                    = 2,
  76.     sleepWakeUp                    = 3,
  77.     sleepRevoke                    = 4,
  78. /* SleepQRec.sleepQFlags */
  79.     noCalls                        = 1,
  80.     noRequest                    = 2,
  81.     slpQType                    = 16,
  82.     sleepQType                    = 16
  83. };
  84.  
  85. /* bits in bitfield returned by PMFeatures */
  86. enum {
  87.     hasWakeupTimer                = 0,                            /* 1=wakeup timer is supported                        */
  88.     hasSharedModemPort            = 1,                            /* 1=modem port shared by SCC and internal modem    */
  89.     hasProcessorCycling            = 2,                            /* 1=processor cycling is supported                    */
  90.     mustProcessorCycle            = 3,                            /* 1=processor cycling should not be turned off        */
  91.     hasReducedSpeed                = 4,                            /* 1=processor can be started up at reduced speed    */
  92.     dynamicSpeedChange            = 5,                            /* 1=processor speed can be switched dynamically    */
  93.     hasSCSIDiskMode                = 6,                            /* 1=SCSI Disk Mode is supported                    */
  94.     canGetBatteryTime            = 7,                            /* 1=battery time can be calculated                    */
  95.     canWakeupOnRing                = 8,                            /* 1=can wakeup when the modem detects a ring        */
  96.     hasDimmingSupport            = 9                                /* 1 has dimming support built into the rom            */
  97. };
  98.  
  99. /* bits in bitfield returned by GetIntModemInfo and set by SetIntModemState */
  100. enum {
  101.     hasInternalModem            = 0,                            /* 1=internal modem installed                        */
  102.     intModemRingDetect            = 1,                            /* 1=internal modem has detected a ring                */
  103.     intModemOffHook                = 2,                            /* 1=internal modem is off hook                        */
  104.     intModemRingWakeEnb            = 3,                            /* 1=wakeup on ring is enabled                        */
  105.     extModemSelected            = 4,                            /* 1=external modem selected                        */
  106.     modemSetBit                    = 15                            /* 1=set bit, 0=clear bit (SetIntModemState)        */
  107. };
  108.  
  109. /* bits in BatteryInfo.flags                                     */
  110. /* ("chargerConnected" doesn't mean the charger is plugged in)    */
  111. enum {
  112.     batteryInstalled            = 7,                            /* 1=battery is currently connected                    */
  113.     batteryCharging                = 6,                            /* 1=battery is being charged                        */
  114.     chargerConnected            = 5                                /* 1=charger is connected to the PowerBook            */
  115. };
  116.  
  117. enum {
  118.     HDPwrQType                    = 'HD'
  119. };
  120.  
  121. typedef struct BatteryInfo BatteryInfo;
  122.  
  123. struct BatteryInfo {
  124.     UInt8                            flags;                        /* misc flags (see below)                            */
  125.     UInt8                            warningLevel;                /* scaled warning level (0-255)                        */
  126.     UInt8                            reserved;                    /* reserved for internal use                        */
  127.     UInt8                            batteryLevel;                /* scaled battery level (0-255)                        */
  128. };
  129. typedef SInt8 ModemByte;
  130.  
  131. typedef SInt8 BatteryByte;
  132.  
  133. typedef long PMResultCode;
  134.  
  135. typedef struct SleepQRec SleepQRec, *SleepQRecPtr;
  136.  
  137. typedef struct HDQueueElement HDQueueElement;
  138.  
  139. typedef pascal void (*HDSpindownProcPtr)(HDQueueElement *theElement);
  140. /*
  141.         SleepQProcPtr uses register based parameters on the 68k and cannot
  142.         be written in or called from a high-level language without the help of
  143.         mixed mode or assembly glue.
  144.  
  145.         In:
  146.          => message         D0.L
  147.          => qRecPtr         A0.L
  148.         Out:
  149.          <= return value    D0.L
  150. */
  151.  
  152. #if GENERATINGCFM
  153. typedef UniversalProcPtr HDSpindownUPP;
  154. typedef UniversalProcPtr SleepQUPP;
  155. #else
  156. typedef HDSpindownProcPtr HDSpindownUPP;
  157. typedef Register68kProcPtr SleepQUPP;
  158. #endif
  159.  
  160. struct HDQueueElement {
  161.     Ptr                                hdQLink;                    /* pointer to next queue element                    */
  162.     short                            hdQType;                    /* queue element type (must be HDQType)                */
  163.     short                            hdFlags;                    /* miscellaneous flags                                */
  164.     HDSpindownUPP                    hdProc;                        /* pointer to routine to call                        */
  165.     long                            hdUser;                        /* user-defined (variable storage, etc.)            */
  166. };
  167. struct SleepQRec {
  168.     struct SleepQRec                *sleepQLink;
  169.     short                            sleepQType;                    /* type = 16                            */
  170.     SleepQUPP                        sleepQProc;                    /* Pointer to sleep universal proc ptr    */
  171.     short                            sleepQFlags;
  172. };
  173. /* wakeup time record */
  174. typedef struct WakeupTime WakeupTime;
  175.  
  176. struct WakeupTime {
  177.     unsigned long                    wakeTime;                    /* wakeup time (same format as current time)        */
  178.     Boolean                            wakeEnabled;                /* 1=enable wakeup timer, 0=disable wakeup timer    */
  179.     SInt8                            filler;
  180. };
  181. /* battery time information (in seconds) */
  182. typedef struct BatteryTimeRec BatteryTimeRec;
  183.  
  184. struct BatteryTimeRec {
  185.     unsigned long                    expectedBatteryTime;        /* estimated battery time remaining                */
  186.     unsigned long                    minimumBatteryTime;            /* minimum battery time remaining                */
  187.     unsigned long                    maximumBatteryTime;            /* maximum battery time remaining                */
  188.     unsigned long                    timeUntilCharged;            /* time until battery is fully charged            */
  189. };
  190. extern pascal OSErr DisableWUTime(void);
  191. extern pascal OSErr SetWUTime(long WUTime);
  192. extern pascal OSErr GetWUTime(long *WUTime, Byte *WUFlag);
  193. extern pascal OSErr BatteryStatus(Byte *Status, Byte *Power);
  194. extern pascal OSErr ModemStatus(Byte *Status);
  195.  
  196. #if !GENERATINGCFM
  197. #pragma parameter __D0 IdleUpdate
  198. #endif
  199. extern pascal long IdleUpdate(void)
  200.  ONEWORDINLINE(0xA285);
  201.  
  202. #if !GENERATINGCFM
  203. #pragma parameter __D0 GetCPUSpeed
  204. #endif
  205. extern pascal long GetCPUSpeed(void)
  206.  TWOWORDINLINE(0x70FF, 0xA485);
  207. extern pascal void EnableIdle(void)
  208.  TWOWORDINLINE(0x7000, 0xA485);
  209. extern pascal void DisableIdle(void)
  210.  TWOWORDINLINE(0x7001, 0xA485);
  211.  
  212. #if !GENERATINGCFM
  213. #pragma parameter SleepQInstall(__A0)
  214. #endif
  215. extern pascal void SleepQInstall(SleepQRecPtr qRecPtr)
  216.  ONEWORDINLINE(0xA28A);
  217.  
  218. #if !GENERATINGCFM
  219. #pragma parameter SleepQRemove(__A0)
  220. #endif
  221. extern pascal void SleepQRemove(SleepQRecPtr qRecPtr)
  222.  ONEWORDINLINE(0xA48A);
  223. extern pascal void AOn(void)
  224.  TWOWORDINLINE(0x7004, 0xA685);
  225. extern pascal void AOnIgnoreModem(void)
  226.  TWOWORDINLINE(0x7005, 0xA685);
  227. extern pascal void BOn(void)
  228.  TWOWORDINLINE(0x7000, 0xA685);
  229. extern pascal void AOff(void)
  230.  TWOWORDINLINE(0x7084, 0xA685);
  231. extern pascal void BOff(void)
  232.  TWOWORDINLINE(0x7080, 0xA685);
  233. /* Public Power Management API (NEW!) */
  234.  
  235. #if !GENERATINGCFM
  236. #pragma parameter __D0 PMSelectorCount
  237. #endif
  238. extern pascal short PMSelectorCount(void)
  239.  TWOWORDINLINE(0x7000, 0xA09E);
  240.  
  241. #if !GENERATINGCFM
  242. #pragma parameter __D0 PMFeatures
  243. #endif
  244. extern pascal unsigned long PMFeatures(void)
  245.  TWOWORDINLINE(0x7001, 0xA09E);
  246.  
  247. #if !GENERATINGCFM
  248. #pragma parameter __D0 GetSleepTimeout
  249. #endif
  250. extern pascal UInt8 GetSleepTimeout(void)
  251.  TWOWORDINLINE(0x7002, 0xA09E);
  252.  
  253. #if !GENERATINGCFM
  254. #pragma parameter SetSleepTimeout(__D0)
  255. #endif
  256. extern pascal void SetSleepTimeout(UInt8 timeout)
  257.  FOURWORDINLINE(0x4840, 0x303C, 0x0003, 0xA09E);
  258.  
  259. #if !GENERATINGCFM
  260. #pragma parameter __D0 GetHardDiskTimeout
  261. #endif
  262. extern pascal UInt8 GetHardDiskTimeout(void)
  263.  TWOWORDINLINE(0x7004, 0xA09E);
  264.  
  265. #if !GENERATINGCFM
  266. #pragma parameter SetHardDiskTimeout(__D0)
  267. #endif
  268. extern pascal void SetHardDiskTimeout(UInt8 timeout)
  269.  FOURWORDINLINE(0x4840, 0x303C, 0x0005, 0xA09E);
  270.  
  271. #if !GENERATINGCFM
  272. #pragma parameter __D0 HardDiskPowered
  273. #endif
  274. extern pascal Boolean HardDiskPowered(void)
  275.  TWOWORDINLINE(0x7006, 0xA09E);
  276.  
  277. #if !GENERATINGCFM
  278. #pragma parameter SpinDownHardDisk
  279. #endif
  280. extern pascal void SpinDownHardDisk(void)
  281.  TWOWORDINLINE(0x7007, 0xA09E);
  282.  
  283. #if !GENERATINGCFM
  284. #pragma parameter __D0 IsSpindownDisabled
  285. #endif
  286. extern pascal Boolean IsSpindownDisabled(void)
  287.  TWOWORDINLINE(0x7008, 0xA09E);
  288.  
  289. #if !GENERATINGCFM
  290. #pragma parameter SetSpindownDisable(__D0)
  291. #endif
  292. extern pascal void SetSpindownDisable(Boolean setDisable)
  293.  FOURWORDINLINE(0x4840, 0x303C, 0x0009, 0xA09E);
  294.  
  295. #if !GENERATINGCFM
  296. #pragma parameter __D0 HardDiskQInstall(__A0)
  297. #endif
  298. extern pascal OSErr HardDiskQInstall(HDQueueElement *theElement)
  299.  TWOWORDINLINE(0x700A, 0xA09E);
  300.  
  301. #if !GENERATINGCFM
  302. #pragma parameter __D0 HardDiskQRemove(__A0)
  303. #endif
  304. extern pascal OSErr HardDiskQRemove(HDQueueElement *theElement)
  305.  TWOWORDINLINE(0x700B, 0xA09E);
  306.  
  307. #if !GENERATINGCFM
  308. #pragma parameter GetScaledBatteryInfo(__D0, __A0)
  309. #endif
  310. extern pascal void GetScaledBatteryInfo(short whichBattery, BatteryInfo *theInfo)
  311.  FIVEWORDINLINE(0x4840, 0x303C, 0x000C, 0xA09E, 0x2080);
  312.  
  313. #if !GENERATINGCFM
  314. #pragma parameter AutoSleepControl(__D0)
  315. #endif
  316. extern pascal void AutoSleepControl(Boolean enableSleep)
  317.  FOURWORDINLINE(0x4840, 0x303C, 0x000D, 0xA09E);
  318.  
  319. #if !GENERATINGCFM
  320. #pragma parameter __D0 GetIntModemInfo
  321. #endif
  322. extern pascal unsigned long GetIntModemInfo(void)
  323.  TWOWORDINLINE(0x700E, 0xA09E);
  324.  
  325. #if !GENERATINGCFM
  326. #pragma parameter SetIntModemState(__D0)
  327. #endif
  328. extern pascal void SetIntModemState(short theState)
  329.  FOURWORDINLINE(0x4840, 0x303C, 0x000F, 0xA09E);
  330.  
  331. #if !GENERATINGCFM
  332. #pragma parameter __D0 MaximumProcessorSpeed
  333. #endif
  334. extern pascal short MaximumProcessorSpeed(void)
  335.  TWOWORDINLINE(0x7010, 0xA09E);
  336.  
  337. #if !GENERATINGCFM
  338. #pragma parameter __D0 CurrentProcessorSpeed
  339. #endif
  340. extern pascal short CurrentProcessorSpeed(void)
  341.  TWOWORDINLINE(0x7011, 0xA09E);
  342.  
  343. #if !GENERATINGCFM
  344. #pragma parameter __D0 FullProcessorSpeed
  345. #endif
  346. extern pascal Boolean FullProcessorSpeed(void)
  347.  TWOWORDINLINE(0x7012, 0xA09E);
  348.  
  349. #if !GENERATINGCFM
  350. #pragma parameter __D0 SetProcessorSpeed(__D0)
  351. #endif
  352. extern pascal Boolean SetProcessorSpeed(Boolean fullSpeed)
  353.  FOURWORDINLINE(0x4840, 0x303C, 0x0013, 0xA09E);
  354.  
  355. #if !GENERATINGCFM
  356. #pragma parameter __D0 GetSCSIDiskModeAddress
  357. #endif
  358. extern pascal short GetSCSIDiskModeAddress(void)
  359.  TWOWORDINLINE(0x7014, 0xA09E);
  360.  
  361. #if !GENERATINGCFM
  362. #pragma parameter SetSCSIDiskModeAddress(__D0)
  363. #endif
  364. extern pascal void SetSCSIDiskModeAddress(short scsiAddress)
  365.  FOURWORDINLINE(0x4840, 0x303C, 0x0015, 0xA09E);
  366.  
  367. #if !GENERATINGCFM
  368. #pragma parameter GetWakeupTimer(__A0)
  369. #endif
  370. extern pascal void GetWakeupTimer(WakeupTime *theTime)
  371.  TWOWORDINLINE(0x7016, 0xA09E);
  372.  
  373. #if !GENERATINGCFM
  374. #pragma parameter SetWakeupTimer(__A0)
  375. #endif
  376. extern pascal void SetWakeupTimer(WakeupTime *theTime)
  377.  TWOWORDINLINE(0x7017, 0xA09E);
  378.  
  379. #if !GENERATINGCFM
  380. #pragma parameter __D0 IsProcessorCyclingEnabled
  381. #endif
  382. extern pascal Boolean IsProcessorCyclingEnabled(void)
  383.  TWOWORDINLINE(0x7018, 0xA09E);
  384.  
  385. #if !GENERATINGCFM
  386. #pragma parameter EnableProcessorCycling(__D0)
  387. #endif
  388. extern pascal void EnableProcessorCycling(Boolean enable)
  389.  FOURWORDINLINE(0x4840, 0x303C, 0x0019, 0xA09E);
  390.  
  391. #if !GENERATINGCFM
  392. #pragma parameter __D0 BatteryCount
  393. #endif
  394. extern pascal short BatteryCount(void)
  395.  TWOWORDINLINE(0x701A, 0xA09E);
  396.  
  397. #if !GENERATINGCFM
  398. #pragma parameter __D0 GetBatteryVoltage(__D0)
  399. #endif
  400. extern pascal Fixed GetBatteryVoltage(short whichBattery)
  401.  FOURWORDINLINE(0x4840, 0x303C, 0x001B, 0xA09E);
  402.  
  403. #if !GENERATINGCFM
  404. #pragma parameter GetBatteryTimes(__D0, __A0)
  405. #endif
  406. extern pascal void GetBatteryTimes(short whichBattery, BatteryTimeRec *theTimes)
  407.  FOURWORDINLINE(0x4840, 0x303C, 0x001C, 0xA09E);
  408.  
  409. #if !GENERATINGCFM
  410. #pragma parameter __D0 GetDimmingTimeout
  411. #endif
  412. extern pascal UInt8 GetDimmingTimeout(void)
  413.  TWOWORDINLINE(0x701D, 0xA09E);
  414.  
  415. #if !GENERATINGCFM
  416. #pragma parameter SetDimmingTimeout(__D0)
  417. #endif
  418. extern pascal void SetDimmingTimeout(UInt8 timeout)
  419.  FOURWORDINLINE(0x4840, 0x303C, 0x001E, 0xA09E);
  420.  
  421. #if !GENERATINGCFM
  422. #pragma parameter DimmingControl(__D0)
  423. #endif
  424. extern pascal void DimmingControl(Boolean enableSleep)
  425.  FOURWORDINLINE(0x4840, 0x303C, 0x001F, 0xA09E);
  426.  
  427. #if !GENERATINGCFM
  428. #pragma parameter __D0 IsDimmingControlDisabled
  429. #endif
  430. extern pascal Boolean IsDimmingControlDisabled(void)
  431.  TWOWORDINLINE(0x7020, 0xA09E);
  432.  
  433. #if !GENERATINGCFM
  434. #pragma parameter __D0 IsAutoSlpControlDisabled
  435. #endif
  436. extern pascal Boolean IsAutoSlpControlDisabled(void)
  437.  TWOWORDINLINE(0x7021, 0xA09E);
  438. enum {
  439.     uppHDSpindownProcInfo = kPascalStackBased
  440.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(HDQueueElement*))),
  441.     uppSleepQProcInfo = kRegisterBased
  442.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  443.          | REGISTER_RESULT_LOCATION(kRegisterD0)
  444.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(long)))
  445.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA0, SIZE_CODE(sizeof(SleepQRecPtr)))
  446. };
  447.  
  448. #if GENERATINGCFM
  449. #define NewHDSpindownProc(userRoutine)        \
  450.         (HDSpindownUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppHDSpindownProcInfo, GetCurrentArchitecture())
  451. #define NewSleepQProc(userRoutine)        \
  452.         (SleepQUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSleepQProcInfo, GetCurrentArchitecture())
  453. #else
  454. #define NewHDSpindownProc(userRoutine)        \
  455.         ((HDSpindownUPP) (userRoutine))
  456. #define NewSleepQProc(userRoutine)        \
  457.         ((SleepQUPP) (userRoutine))
  458. #endif
  459.  
  460. #if GENERATINGCFM
  461. #define CallHDSpindownProc(userRoutine, theElement)        \
  462.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppHDSpindownProcInfo, (theElement))
  463. #define CallSleepQProc(userRoutine, message, qRecPtr)        \
  464.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSleepQProcInfo, (message), (qRecPtr))
  465. #else
  466. #define CallHDSpindownProc(userRoutine, theElement)        \
  467.         (*(userRoutine))((theElement))
  468. /* (*SleepQProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  469. #endif
  470.  
  471.  
  472. #ifdef __CFM68K__
  473. #pragma lib_export off
  474. #endif
  475.  
  476. #if GENERATINGPOWERPC
  477. #pragma options align=reset
  478. #endif
  479.  
  480. #ifdef __cplusplus
  481. }
  482. #endif
  483.  
  484. #endif /* __POWER__ */
  485.